import * as actionType from "./actionType";
import axios from "axios";
import {fromJS} from "immutable";

const changeList = (inputList) =>{
    return {
        type : actionType.CHANGE_LIST,
        inputList: fromJS(inputList)
    }
}

export const getSearchFlag = () => {
    return {
        type : actionType.SEARCH_FLAG
    }
}

export const dispatchHoldAction = () => {
    return {
        type : actionType.HOLD_FLAG
    }
}

export const changePage = () => {
    return {
        type : actionType.CHANGE_PAGE
    }
}

export const getInputList = () => {
    return (dispatch) => {
        axios.get("/api/searchList.json").then((res) => {
            dispatch(changeList(res.data));
        }).catch(() => {
            console.log("network error");
        })
    }
}